import { createApp } from 'vue';
import App from './App.vue';

import router from './app-router';
import { createWebHistory, type RouterHistory } from 'vue-router';

let win = window as any;

let app: any = null;
let history: any = null;

win.mount = () => {
  history = createWebHistory();
  app = createApp(App);
  app.use(router);
  app.mount('#app');
};

win.unmount = () => {
  app.unmount();
  history.destroy();
  app = null;
  history = null;
};

if (!win.__MICRO_APP_ENVIRONMENT__) {
  win.mount();
}
